import request from '@/utils/request'

// 登录方法
export function login(val) {
  const data = {
    loginName: val.username,
    loginPwd: val.password,
    verificationCode: val.code
  }
  return request({
    url: '/backstageLogin',
    method: 'post',
    data: data
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/getInfo',
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 获取验证码
/* export function getCode(username, password) {
  const data = {
    terminal: 3,  //终端类型 1-大屏端 2-移动端 3-系统后台
    loginName: username,
    loginPwd: password,
  }
  return request({
    url: '/getVerificationCode',
    method: 'post',
    data: data
  })
} */
export function getCode(username) {
  const data = {
    terminal: 3,  //终端类型 1-大屏端 2-移动端 3-系统后台
    loginName: username,
  }
  return request({
    url: '/getVerificationCode',
    method: 'post',
    data: data
  })
}

// 忘记密码 forgetPwdAdmin
export function forgetPwd(username, password, code) {
  const data = {
    projectContent:{
      loginName: username, //登录账号、工号、手机号
      newPwd: password, //新密码
      verificationCode: code //短信验证码
    }
  }
  return request({
    url: '/forgetPwdAdmin',
    method: 'post',
    data: data
  })
}

// 修改密码
export function changePwd(val) {
  const data = {
    projectContent: {
      theid: val.theid,
      oldPwd: val.oldPwd,
      newPwd: val.newPwd,
    }
  }
  return request({
    url: '/changePwdAdmin',
    method: 'post',
    data: data
  })
}